<h1><?php echo __($form['type']->getValue() . " muutmine/lisamine") ?></h1>
<form action="<?php echo LinkGen::getInstance(LinkGen::STRUCTURE_ACTIONS)->link(null, array('module' => 'memberzoneAddresses', 'action' => 'submit', 'addressID' => $form->isNew() ? false : $form['id']->getValue())) ?>" method="post">
<?php echo $form->renderHiddenFields(true) ?>
<div id="comment_flashes"></div>
<div class="korvinfobox andmed">
	<div class="andmerow">
		<div class="arowname">
			<p><?php echo __('name') ?></p>
		</div>
		<div class="aform">
			<div class="aformcontent">
				<div class="formleft"><img src="/enermaatik/img/formleft.png" width="10" height="30" alt=""/></div>
				<div class="formcenter">
					<?php echo $form['name']->render(array('class' => 'ainput')) ?>
				</div>
				<div class="formright"><img src="/enermaatik/img/formright.png" width="10" height="30" alt=""/></div>
			<div class="clear"></div>

		</div>
		</div>
		<div class="akohustlik">
			<img src="/enermaatik/img/koh.png" width="6" height="4" alt=""/>
		</div>
		<div class="clear"></div>
	</div>
	<div class="andmerow">
		<div class="arowname">
			<p><?php echo __('address') ?></p>
		</div>
		<div class="aform">
			<div class="aformcontent">
				<div class="formleft"><img src="/enermaatik/img/formleft.png" width="10" height="30" alt=""/></div>
				<div class="formcenter">
					<?php echo $form['address']->render(array('class' => 'ainput')) ?>
				</div>
				<div class="formright"><img src="/enermaatik/img/formright.png" width="10" height="30" alt=""/></div>
			<div class="clear"></div>

		</div>
		</div>
		<div class="akohustlik">
			<img src="/enermaatik/img/koh.png" width="6" height="4" alt=""/>
		</div>
		<div class="clear"></div>
	</div>
	<div class="andmerow">
		<div class="arowname">
			<p><?php echo __('phone') ?></p>
		</div>
		<div class="aform">
			<div class="aformcontent">
				<div class="formleft"><img src="/enermaatik/img/formleft.png" width="10" height="30" alt=""/></div>
				<div class="formcenter">
					<?php echo $form['phone']->render(array('class' => 'ainput')) ?>
				</div>
				<div class="formright"><img src="/enermaatik/img/formright.png" width="10" height="30" alt=""/></div>
			<div class="clear"></div>

		</div>
		</div>
		<div class="akohustlik">
			<img src="/enermaatik/img/koh.png" width="6" height="4" alt=""/>
		</div>
		<div class="clear"></div>
	</div>
	<div class="andmerow">
		<div class="arowname">
			<p><?php echo __('city') ?></p>
		</div>
		<div class="aform">
			<div class="aformcontent">
				<div class="formleft"><img src="/enermaatik/img/formleft.png" width="10" height="30" alt=""/></div>
				<div class="formcenter">
					<?php echo $form['city']->render(array('class' => 'ainput')) ?>
				</div>
				<div class="formright"><img src="/enermaatik/img/formright.png" width="10" height="30" alt=""/></div>
			<div class="clear"></div>

		</div>
		</div>
		<div class="akohustlik">
			<img src="/enermaatik/img/koh.png" width="6" height="4" alt=""/>
		</div>
		<div class="clear"></div>
	</div>
	<div class="andmerow">
		<div class="arowname">
			<p><?php echo __('country') ?></p>
		</div>
		<div class="aform">
			<div class="aformcontent">
				<div class="formleft"><img src="/enermaatik/img/formleft.png" width="10" height="30" alt=""/></div>
				<div class="formcenter">
					<?php echo $form['country']->render(array('class' => 'ainput')) ?>
				</div>
				<div class="formright"><img src="/enermaatik/img/formright.png" width="10" height="30" alt=""/></div>
			<div class="clear"></div>

		</div>
		</div>
		<div class="akohustlik">
			<img src="/enermaatik/img/koh.png" width="6" height="4" alt=""/>
		</div>
		<div class="clear"></div>
	</div>
	<div class="andmerow">
		<div class="arowname">
			<p><?php echo __('region') ?></p>
		</div>
		<div class="aform">
			<div class="aformcontent">
				<div class="formleft"><img src="/enermaatik/img/formleft.png" width="10" height="30" alt=""/></div>
				<div class="formcenter">
					<?php echo $form['state']->render(array('class' => 'ainput')) ?>
				</div>
				<div class="formright"><img src="/enermaatik/img/formright.png" width="10" height="30" alt=""/></div>
			<div class="clear"></div>

		</div>
		</div>
		<div class="akohustlik">
			<img src="/enermaatik/img/koh.png" width="6" height="4" alt=""/>
		</div>
		<div class="clear"></div>
	</div>
	<div class="andmerow">
		<div class="arowname">
			<p><?php echo __('zip') ?></p>
		</div>
		<div class="aform">
			<div class="aformcontent">
				<div class="formleft"><img src="/enermaatik/img/formleft.png" width="10" height="30" alt=""/></div>
				<div class="formcenter">
					<?php echo $form['zip']->render(array('class' => 'ainput')) ?>
				</div>
				<div class="formright"><img src="/enermaatik/img/formright.png" width="10" height="30" alt=""/></div>
			<div class="clear"></div>

		</div>
		</div>
		<div class="akohustlik">
			<img src="/enermaatik/img/koh.png" width="6" height="4" alt=""/>
		</div>
		<div class="clear"></div>
	</div>
	<div class="clear"></div>
</div>
<div class="ccontentmainbottom"></div>
<div class="clear"></div>
<div class="tablebuttons">
	<div class="hallbutton">
		<div class="hallbuttonleft"><img src="/enermaatik/img/tbl.png" width="8" height="26" alt=""/></div>
		<div class="hallbuttoncenter">

			<p><a id="submit_button" href="#"><?php echo __('salvesta') ?></a></p>
		</div>
		<div class="hallbuttonright"><img src="/enermaatik/img/tbr.png" width="8" height="26" alt=""/></div>
		<div class="clear"></div>
	</div>
	<div class="clear"></div>
</div>
</form>

<script type="text/javascript">
$('#submit_button').click(function(e){
	e.preventDefault();


	var button = $(this);
	var form = button.parents('form');

	button.hide();

	$('#comment_flashes').html('');

	$.post(form.attr('action'), form.serialize(), function(data){
		button.show();


		if(data.status == 200){
			$('#comment_flashes').html(data.shortMessage);
		}else{
			for (var i in data.messages ){
				$('#comment_flashes').html( $('#comment_flashes').html() + "<br />" +  data.messages[i]);
			}
			button.show();
		}

	}, 'json');

	return false;
});
</script>